﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using F_MODEL;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace F_DAL
{
   public class per_dal
    {
       static string ConnectString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
        /// <summary>
        /// 个人寄货单
        /// </summary>
        /// <returns></returns>
        public List<Mails> ji_list(int id)
        {
            string sql = "select * from mails m INNER JOIN UserInfo ui ON ui.Userid = m.Userid  where m.Userid=" + id + "";
            SqlConnection conn = new SqlConnection(ConnectString);
            conn.Open();
            SqlCommand command = new SqlCommand(sql, conn);
            SqlDataReader read = command.ExecuteReader();
            List<Mails> MList = new List<Mails>();
            while (read.Read())
            {
                Mails m = new Mails();
                m.dweight = Convert.ToString(read["dweight"]);
                m.isFlyman = Convert.ToInt32(read["isFlyman"]);
                m.goodsImg = Convert.ToString(read["goodsImg"]);
                m.mailId = Convert.ToString(read["mailId"]);
                m.mailIsDel = Convert.ToInt32(read["mailIsDel"]);
                m.mailStatus = Convert.ToInt32(read["mailStatus"]);
                m.mailTimeSpan = Convert.ToDateTime(read["mailTimeSpan"]);
                m.ParCeId = Convert.ToInt32(read["ParCeId"]);
                m.predictPrice = Convert.ToDecimal(read["predictPrice"]);
                m.receiveUser = Convert.ToString(read["receiveUser"]);
                m.sendUser = Convert.ToString(read["sendUser"]);
                m.stationId = Convert.ToInt32(read["stationId"]);
                m.types1 = Convert.ToString(read["types1"]);
                m.Userid = Convert.ToInt32(read["Userid"]);
                MList.Add(m);
            }
            return MList;

        }

        /// <summary>
        /// 个人收货单
        /// </summary>
        /// <returns></returns>
        public List<Temp> shou_list(int id)
        {

            string sql = "select * from Waybill inner join WaybillMailMapping on WaybillMailMapping.waybillId=Waybill.waybillId inner join mails on mails.mailId=WaybillMailMapping.mailId where Waybill.userId=" + id + "";
            SqlConnection conn = new SqlConnection(ConnectString);
            conn.Open();
            SqlCommand command = new SqlCommand(sql, conn);
            SqlDataReader read = command.ExecuteReader();
            List<Temp> MList = new List<Temp>();
            while (read.Read())
            {
                Temp m = new Temp();
                m.dweight = Convert.ToString(read["dweight"]);
                m.goodsImg = Convert.ToString(read["goodsImg"]);
                m.mailId = Convert.ToString(read["mailId"]);
                m.mailIsDel = Convert.ToInt32(read["mailIsDel"]);
                m.mailStatus = Convert.ToInt32(read["mailStatus"]);
                m.mailTimeSpan = Convert.ToDateTime(read["mailTimeSpan"]);
                m.ParCeId = Convert.ToInt32(read["ParCeId"]);
                m.predictPrice = Convert.ToDecimal(read["predictPrice"]);
                m.receiveUser = Convert.ToString(read["receiveUser"]);
                m.sendUser = Convert.ToString(read["sendUser"]);
                m.types1 = Convert.ToString(read["types1"]);
                m.Userid = Convert.ToInt32(read["Userid"]);
                m.waybillId = Convert.ToString(read["waybillId"]);
                m.userId = Convert.ToInt32(read["userId"]);
                m.origin = Convert.ToString(read["origin"]);
                m.destination = Convert.ToString(read["destination"]);
                m.submitTime = Convert.ToDateTime(read["submitTime"]);
                MList.Add(m);
            }
            return MList;
        }

    }
}
